<?php $this->context->layout = 'form';?>
<?= \common\widgets\Asset::widget(['type'=>['viewer']])?>
<form class="form-horizontal m" id="form-admin-add">
    <table class="table table-striped">
        <tr>
            <th>申请人</th>
            <td><?=$userHtml?></td>
        </tr>
        <tr>
            <th>订单号</th>
            <td>
                <?=$info['order_sn']?>
            </td>
        </tr>
        <tr>
            <th>申请退款金额</th>
            <td><?=$info['amount']?></td>
        </tr>
        <?php if ($info['already_amount']>0):?>
            <tr>
                <th>已退款金额</th>
                <td><?=$info['already_amount']?></td>
            </tr>
        <?php endif;?>
        <?php if ($info['content']):?>
            <tr>
                <th>申请原因</th>
                <td><?=$info['content']?></td>
            </tr>
        <?php endif;?>
        <?php if ($info['imgs']):?>
            <tr>
                <th>图片</th>
                <td>
                    <div id="id_card">
                        <?php foreach ($info['imgs'] as $img):?>
                            <img src="<?=$img?>" alt="" style="width: 100px">
                        <?php endforeach;?>
                    </div>
                </td>
            </tr>
        <?php endif;?>
        <tr>
            <th>申请退款金额</th>
            <td><?=$info['amount']?></td>
        </tr>
        <?php if ($info['review_status']!=='0'):?>
            <tr>
                <th>审核状态</th>
                <td>
                    <?=$review_status[$info['review_status']]??''?>
                </td>
            </tr>
            <tr>
                <th>审核备注</th>
                <td>
                    <?=$info['review_remarks']?>
                </td>
            </tr>
            <tr>
                <th>审核时间</th>
                <td>
                    <?=$info['review_time']?>
                </td>
            </tr>
        <?php else:?>
            <tr>
                <th style="text-align: unset;" class="control-label is-required">退款金额</th>
                <td>
                    <input type="number" class="form-control" name="amount" value="<?=$info['surplus']?>" required>
                    <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 审核通过，退款金额将原路返回，退款金额不能大于订单金额</span>
                </td>
            </tr>
            <tr>
                <th style="text-align: unset;" class="control-label is-required">审核</th>
                <td>
                    <?= \common\widgets\FormInput::widget(['name'=>'radio','extend'=>['name'=>'review_status','required'=>1,'data'=>$review_status]])?>
                </td>
            </tr>
            <tr>
                <th>审核备注</th>
                <td>
                    <?= \common\widgets\FormInput::widget(['name'=>'textarea','extend'=>['name'=>'review_remarks']])?>
                </td>
            </tr>
        <?php endif;?>
    </table>
    <input type="hidden" name="id" value="<?=$info['id']?>">
</form>

<?php $this->beginBlock('script'); ?>
<script>
    var elem = document.getElementById('id_card');
    if (elem){
        new Viewer(document.getElementById('id_card'),{navbar:false,title:false});
    }
    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save("<?=\yii\helpers\Url::to(['order/refund-review'])?>", $('#form-admin-add').serialize());
        }
    }
</script>
<?php $this->endBlock(); ?>
